home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / dev / fsystem-1.2 / flrealio.mod < prev    next >
Encoding:
Text File  |  1994-05-22  |  3.0 KB  |  97 lines

  1. (* (* $VER: fLRealIO 1.1 (21-May-94) Copyright © by Lars Düning *) *)
  2.  
  3. MODULE fLRealIO;
  4.  
  5. (*---------------------------------------------------------------------------
  6. ** File-IO of LONGREAL numbers for Amiga-Oberon.
  7. **
  8. ** Copyright © 1991-1994  Lars Düning  -  All rights reserved.
  9. ** Permission granted for non-commercial use.
  10. **---------------------------------------------------------------------------
  11. ** CREDIT:
  12. **   This module evolved from RealIO of Amiga-Oberon v1.17.1
  13. **---------------------------------------------------------------------------
  14. ** Oberon-2: Amiga-Oberon v3.10, F. Siebert / A+L AG
  15. **---------------------------------------------------------------------------
  16. ** [lars] Lars Düning; Am Wendenwehr 25; D-38114-Braunschweig;
  17. **                     Germany; Tel. 49-531-345692
  18. **---------------------------------------------------------------------------
  19. ** 01-Jan-91 [lars]
  20. ** 21-May-04 [lars] Moved ParseReal() from fio to fRealIO.
  21. **---------------------------------------------------------------------------
  22. *)
  23.  
  24. IMPORT
  25.   (* $IF Debug *) Debug, (* $END *)
  26.   fio, fRealIO, rc: LongRealConversions;
  27.  
  28. (*-------------------------------------------------------------------------*)
  29. PROCEDURE writeReal * {"fLRealIO.WriteReal"}
  30.                       ( VAR    f : fio.File
  31.                       ;        r : LONGREAL
  32.                       ;     v, n : INTEGER
  33.                       ;      exp : BOOLEAN
  34.                       );
  35. PROCEDURE WriteReal * ( VAR    f : fio.File
  36.                       ;        r : LONGREAL
  37.                       ;     v, n : INTEGER
  38.                       ;      exp : BOOLEAN
  39.                       ): BOOLEAN;
  40.  
  41. (* Write a REAL number into a file.
  42. **
  43. ** Arguments:
  44. **   f  : the file to write to.
  45. **   r  : the number to write.
  46. **   v  : number of digits in front of the '.'
  47. **   n  : number of digits after the '.'
  48. **   exp: if TRUE, the 'E' notation is used when appropriate.
  49. **
  50. ** Result:
  51. **   TRUE on success, else FALSE with out.status denoting the error.
  52. **     If FALSE is returned, but out.status is 'ok', then the number is
  53. **     larger than the allowed number of digits.
  54. *)
  55.  
  56. VAR
  57.   str: ARRAY 256 OF CHAR;
  58.  
  59. BEGIN
  60.   IF rc.RealToString(r,str,v,n,exp) THEN
  61.     RETURN fio.WriteString(f,str);
  62.   ELSE
  63.     RETURN FALSE;
  64.   END;
  65. END WriteReal;
  66.  
  67. (*-------------------------------------------------------------------------*)
  68. PROCEDURE readReal * {"fLRealIO.ReadReal"}(VAR f : fio.File; VAR r: LONGREAL);
  69. PROCEDURE ReadReal * (VAR f : fio.File; VAR r: LONGREAL): BOOLEAN;
  70.  
  71. (* Read a REAL number from a file.
  72. **
  73. ** Arguments:
  74. **   f  : the file to read from.
  75. **   r  : variable to take the number read.
  76. **
  77. ** Result:
  78. **   TRUE on success, else FALSE with out.status denoting the error.
  79. **     If FALSE is returned, but out.status is 'ok', then no correct number
  80. **     could be read.
  81. **   r: the number read.
  82. *)
  83.  
  84. VAR
  85.   str: ARRAY 256 OF CHAR;
  86.  
  87. BEGIN
  88.   IF fRealIO.ParseReal(f, str) THEN
  89.     RETURN rc.StringToReal(str,r);
  90.   END;
  91.   RETURN FALSE;
  92. END ReadReal;
  93.  
  94. END fLRealIO.
  95.  
  96. (***************************************************************************)
  97.